package com.mayi.zds.dao;

import com.mayi.zds.dao.param.OrderQueryParam;
import com.mayi.zds.dao.provider.OrderProvider;
import com.mayi.zds.entity.Order;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @ClassName OrderDAO
 * @Description TODO
 * @Author zhong
 * @Date 2019/12/24 0024 下午 4:20
 * @Version 1.0
 */
@Repository
public interface OrderDAO {
    /**
     * 增加订单
     * @Author zhong
     * @Date 2019/12/24 16:42:12
     * @param order
     * @return void
     **/
    @Insert("insert into zds_order values(#{id}, #{userId},#{orderNo} ,#{orderTime}, #{payType}, #{payTime},#{busiAcceptTime},#{riderId}," +
            "#{riderAcceptTime}, #{completionTime}, #{totalMoney},#{discountedMoney},#{deliveryFee}, #{address}, #{accept}, #{acceptTelephone}, #{deliveryType}, #{expectTime}, #{status},#{userMessage},#{businessId})")
    public void add(Order order);

    /**
     *
     * //TODO 根据条件查询订单
     * @Author zhong
     * @Date 2019/12/24 16:35:27
     * @param orderQueryParam 查询参数
     * @return java.util.List<com.mayi.zds.entity.Order>
     **/
    @SelectProvider(type = OrderProvider.class,method = "getListByConditions")
    public List<Order> getListByConditions(OrderQueryParam orderQueryParam);

    /**
     * 通过订单ID查询订单
     * @Author zhong
     * @Date 2019/12/25 22:27:01
     * @param id 订单id
     * @return com.mayi.zds.entity.Order
     **/
    @Select("select * from zds_order where id=#{id}")
    public Order getById(String id);

    /**
     * 取消订单
     * @Author zhong
     * @Date 2019/12/26 00:20:27
     * @param id 订单ID
     * @return void
     **/
    @Update("UPDATE zds_order SET status='6' WHERE id=#{id}")
    public void updateStatusToCancle(String id);

    /**
     * 完成订单
     * @Author zhong
     * @Date 2019/12/26 15:56:50
     * @param id 订单ID
     * @return void
     **/
    @Update("UPDATE zds_order SET status='5' WHERE id=#{id}")
    public void updateStatusToFinish(String id);
}
